package com.millstein.tsinglog.utils;

import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {

    /**
     * 获取今天的日期
     * @return
     */
    public static Date getTodayDate() throws ParseException {
        return ConcurrentDateUtils.parse(ConcurrentDateUtils.format(new Date()).substring(0, 11) + "00:00:00");
    }


    /**
     * 获取本月第一天的日期
     * @return
     */
    public static Date getFirstDayForMonth() throws ParseException {
        Date date = new Date();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.MONTH, 0);
        calendar.set(Calendar.DAY_OF_MONTH, 1); // 设置为1号,当前日期既为本月第一天
        Date firstDay = calendar.getTime();
        return ConcurrentDateUtils.parse(ConcurrentDateUtils.format(firstDay).substring(0, 11) + "00:00:00");
    }

}
